package com.itheima.study.dubbo.controller;


import com.itheima.study.dubbo.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @DubboReference
    private UserService userService;

    @RequestMapping("login")
    public String login(String username, String password) {
        log.info("[用户-登录]username:{}，password:{}", username, password);
        // rpc调用UserService进行登录操作
        if (userService.login(username, password)) {
            return "login success !";
        }
        return "login fail !";
    }
}
